﻿Imports System.Net
Imports System.Text
Imports System.IO

Public Class Form1
    Dim wordArr As String()
    Dim tanggal As String
    Dim judul As String
    Dim ayat As String
    Dim isi As String
    Dim todays As Integer
    Dim dayname As String
    Dim kata As String



    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

    End Sub

    Private Sub Label5_Click(sender As Object, e As EventArgs) Handles Label5.Click

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label6.Text = System.DateTime.Now.ToString("dddd, dd / MM / yyyy") 'current time--------
        todays = DateTime.Parse(System.DateTime.Now.ToString("yyyy/MM/dd")).DayOfWeek
        If todays = 1 Then
            kata = "kode=1"
        ElseIf todays = 2 Then
            kata = "kode=2"
        ElseIf todays = 3 Then
            kata = "kode=3"
        ElseIf todays = 4 Then
            kata = "kode=4"
        ElseIf todays = 5 Then
            kata = "kode=5"
        ElseIf todays = 6 Then
            kata = "kode=6"
        ElseIf todays = 7 Then
            kata = "kode=7"
        End If

        'Label2.Text = kata
        loaded()
        Label1.BackColor = Color.FromArgb(130, 255, 255, 204)
        Label5.BackColor = Color.FromArgb(130, 255, 255, 204)
        Label4.BackColor = Color.FromArgb(130, 255, 255, 204)


        ComboBox1.Items.Add("Monday")
        ComboBox1.Items.Add("Tuesday")
        ComboBox1.Items.Add("Wednesday")
        ComboBox1.Items.Add("Thursday")
        ComboBox1.Items.Add("Friday")
        ComboBox1.Items.Add("Saturday")
        ComboBox1.Items.Add("Sunday")

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

        If ComboBox1.SelectedIndex = 0 Then
            kata = "kode=1"
        ElseIf ComboBox1.SelectedIndex = 1 Then
            kata = "kode=2"
        ElseIf ComboBox1.SelectedIndex = 2 Then
            kata = "kode=3"
        ElseIf ComboBox1.SelectedIndex = 3 Then
            kata = "kode=4"
        ElseIf ComboBox1.SelectedIndex = 4 Then
            kata = "kode=5"
        ElseIf ComboBox1.SelectedIndex = 5 Then
            kata = "kode=6"
        ElseIf ComboBox1.SelectedIndex = 6 Then
            kata = "kode=7"
        End If

        loaded()
    End Sub

    Public Sub loaded()
        Dim request As WebRequest = WebRequest.Create("http://technubi.com/sand-android/pbk.php")

        request.Method = "POST"
        Dim hasilAyat As String

        Dim byteArray As Byte() = Encoding.UTF8.GetBytes(kata)
        request.ContentType = "application/x-www-form-urlencoded"
        request.ContentLength = byteArray.Length
        Dim dataStream As Stream = request.GetRequestStream()
        dataStream.Write(byteArray, 0, byteArray.Length)
        dataStream.Close()
        Dim response As WebResponse = request.GetResponse()
        Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
        dataStream = response.GetResponseStream()
        Dim reader As New StreamReader(dataStream, Encoding.UTF8)
        Dim responseFromServer As String = reader.ReadToEnd()
        If responseFromServer = "0" Then
            Label1.Text = "No Data Found"
        Else
            hasilAyat = responseFromServer
            wordArr = hasilAyat.Split("$")
            tanggal = wordArr(1)
            judul = wordArr(0)
            ayat = wordArr(2)
            isi = wordArr(3)

        End If
        reader.Close()
        dataStream.Close()
        response.Close()
        Label1.Text = judul
        Label3.Text = tanggal
        Label4.Text = isi
        Label5.Text = ayat

    End Sub

    Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click

    End Sub
End Class
